#ifndef CORESPLITTER_HPP
#define CORESPLITTER_HPP

#include <vector>
#include "coredataqueue.hpp"
#include "coredataunit.hpp"
#include "coreconfigdefs.hpp"

namespace pland
{

class Splitter
{
public:
    virtual void loadQueues(SharedDQueue front, std::vector<SharedDQueue> back) = 0;
    virtual bool start() = 0;
    virtual bool stop() = 0;
};

class Splitter_Copy : public Splitter
{
public:
    Splitter_Copy();
    void loadQueues(SharedDQueue front, std::vector<SharedDQueue> back);
    bool start();
    bool stop();
private:
    SharedDQueue front_;
    std::vector<SharedDQueue> back_;

    boost::shared_mutex mutex_;
    bool running_;
    boost::thread thread_;
    void start_();

};

class Splitter_Balancer : public Splitter
{
public:
    Splitter_Balancer();
    void loadQueues(SharedDQueue front, std::vector<SharedDQueue> back);
    bool start();
    bool stop();
private:
    uint turn;
    SharedDQueue front_;
    std::vector<SharedDQueue> back_;

    boost::shared_mutex mutex_;
    bool running_;
    boost::thread thread_;
    void start_();
};

}
#endif // CORESPLITTER_HPP
